#include("/admin/common/header.html")
#include("/admin/common/footer.html")
#include("/admin/common/left.html")
#include("/admin/common/layout.html")


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Myopen</title>
<link rel="stylesheet" href="#(ctx_path)/plugins/layui/css/layui.css">

</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
	
		#@header()

		<div class="layui-body" style="left:0px;">
			<!-- 内容主体区域 -->
			<div style="padding: 10px;width: 100%;" align="center">
				<form class="layui-form" action=""  style="width: 350px;">
			
						<div class="layui-form-item">
							<div class="layui-input-block" align="center" style="font-size: 18px;margin-left: 0px;">
								<br/>
								<br/>
								<br/>
								<b>密码修改</b><br/>
							</div>
						</div>
						
						<div class="layui-form-item">
							<div class="layui-input-block" style="margin-left: 0px;">
								<input type="password" name="password" lay-verify="password" autocomplete="off" placeholder="请输入原密码" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<div class="layui-input-block" style="margin-left: 0px;">
								<input type="password" name="password_new" lay-verify="password_new" autocomplete="off" placeholder="请输入新密码" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<div class="layui-input-block" style="margin-left: 0px;">
								<input type="password" name="password_new_2" lay-verify="password_new_2" autocomplete="off" placeholder="请再次输入新密码" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<div class="layui-input-block" style="margin-left: 0px;">
								<button class="layui-btn" type="button" onclick="doUpdatePassword();" style="width: 100%;">修改</button>
							</div>
						</div>
						
					</form>
				</div>
			
		</div>

		<div class="layui-footer" style="left:0px;" align="center">
			#@footer()
		</div>
		
	</div>
	
	
	<script src="#(ctx_path)/plugins/layui/layui.js"></script>
	<script src="#(ctx_path)/plugins/jquery/1.11.3/jquery.min.js"></script>
	<script src="#(ctx_path)/plugins/jquery.cookie/jquery.cookie.js"></script>
	<script src="#(ctx_path)/plugins/ckeditor/ckeditor.js"></script>
	<script src="#(ctx_path)/plugins/ckeditor.my/ckeditor.my.js"></script>
	
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
	  <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	  <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
	
	<script type="text/javascript">
		
		layui.config({
			base : '/plugins/layui.custom/' 
		}).extend({ //设定模块别名
			treeSelect : 'treeSelect'
		});

		
	</script>
	
	<script type="text/javascript">
		//注意：导航 依赖 element 模块，否则无法进行功能性操作
		
		layui.use(['element','table','layer','tree','treeSelect','laytpl'], function() {
			var table = layui.table;
			var element = layui.element;
			var table = layui.table;
			var $ = layui.$;
			var layer = layui.layer;
			var tree = layui.tree;
			var laytpl = layui.laytpl;
			
			//…
		});
		
		function doUpdatePassword(){
			var password=$(":input[name='password']").val();
	  		var password_new=$(":input[name='password_new']").val();
	  		var password_new_2=$(":input[name='password_new_2']").val();
	  		
	  		if(password==""){
	  			layer.open({
					type : 1,
					content : '<div style="padding: 20px 100px;">请输入原密码</div>',
					btn : '确认',
					btnAlign : 'c',
					shade : 0.5,
					yes : function() {
						layer.closeAll();
					}
				});
	  			return;
	  		}
	  		
	  		if(password_new==""){
	  			layer.open({
					type : 1,
					content : '<div style="padding: 20px 100px;">请输入新密码</div>',
					btn : '确认',
					btnAlign : 'c',
					shade : 0.5,
					yes : function() {
						layer.closeAll();
					}
				});
	  			return;
	  		}
	  		if(password_new_2==""){
	  			layer.open({
					type : 1,
					content : '<div style="padding: 20px 100px;">请再次输入新密码</div>',
					btn : '确认',
					btnAlign : 'c',
					shade : 0.5,
					yes : function() {
						layer.closeAll();
					}
				});
	  			return;
	  		}
	  		
	  		if(password_new!=password_new_2){
	  			layer.open({
					type : 1,
					content : '<div style="padding: 20px 100px;">两次输入的密码不一致</div>',
					btn : '确认',
					btnAlign : 'c',
					shade : 0.5,
					yes : function() {
						layer.closeAll();
					}
				});
	  			return;
	  		}
	  		
	  		$.ajax({
	  		  type:'get',
	  		  url:'#(ctx_path)/admin/my/password/update/action',
	  		  data:$("form").serialize(),
	  		  success:function(data){
	  			  if(data.code=="0"){
	  				layer.open({
						type : 1,
						content : '<div style="padding: 20px 100px;">修改成功</div>',
						btn : '确认',
						btnAlign : 'c',
						shade : 0.5,
						yes : function() {
							layer.closeAll();
							window.location.href='#(ctx_path)/admin';
						}
					});
	  			  }else{
	  				  
	  				  var text="";
	  				  if(data.code=="1"){
	  					  text="原密码错误";
	  				  }
	  				  
	  				  layer.open({
	  						type : 1,
	  						content : '<div style="padding: 20px 100px;">'+text+'</div>',
	  						btn : '确认',
	  						btnAlign : 'c',
	  						shade : 0.5,
	  						yes : function() {
	  							layer.closeAll();
	  						}
	  					});
	  				}
	  	
	  			}
	  		});
	  		
		}
		
	</script>
	
</body>
</html>
